package stackdemo;

import java.util.Stack;

public class Test {

    public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();
        stack.push(1);
        stack.push(2);
        stack.push(3);
        stack.push(4);
        System.out.println(stack);

        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.peek());
        System.out.println(stack.peek());
    }



    public static void main1(String[] args) {
        Stack<Integer> stack = new Stack<>();
        stack.push(12);
        stack.push(23);
        stack.push(34);
        stack.push(45);
        stack.push(56);
        stack.push(67);

        System.out.println(stack);

        //弹出的是栈顶元素（最后放入的元素）会从中删除
        System.out.println(stack.pop());
        System.out.println(stack.pop());

        //只获取栈顶元素的信息，不删除
        System.out.println(stack.peek());
        System.out.println(stack.peek());

    }
}
